<template>
  <kit-page
    :title="title"
    :desc="desc"
    :routes="parentArr"
    :loading="loading"
    :padding="padding"
    footerAlign="center"
  >
    <div slot="footer" style="margin-top: 20px">
      <el-button type="primary" v-lock="btnLocked" @click="doSubmit()"> 保 存 </el-button>
      <el-button @click="doClosePage()">关 闭</el-button>
    </div>

    <kit-chapter title="基础信息" style="margin-bottom: 20px"> </kit-chapter>

    <!--表单-->
    <el-form ref="kitForm" :model="formModel" :rules="rules" label-width="100px">
      <kit-form-wrapper>
      <#list formList as field>
          <kit-form-item label="${(field.comment)!}" prop="${field.javaColumName}">
            <el-input
              :disabled="isDetail || isApprovable"
              v-model="formModel.${field.javaColumName}"
              placeholder="请输入"
            ></el-input>
          </kit-form-item>
      </#list>
      </kit-form-wrapper>
    </el-form>
  </kit-page>
</template>

<script>
import FormMixin from 'kitframe-web/mixins/formPage';

export default {
  name: '${entity}Form',
  mixins: [FormMixin],
  data() {
    return {
      mainPagePath: '/${module}/${entity}List',
      formModel: {
      <#list formList as field>
        ${field.javaColumName}: '',
      </#list>
      },
      rules: {
      },
    };
  },
  methods: {
    onInit() {
      if (this.isEditable) {
        this.$api.${module}.getDetail(this.query.id).then(res => {
          this.formModel = { ...res.data };
        });
      }
    },
    doAdd() {
      const params = this.formModel;
      return this.$api.${module}.saveRow(params);
    },
    doEdit() {
      const params = this.formModel;
      return this.$api.${module}.updateRow(params);
    },
  },
};
</script>
